package com.feijiang.util;

import lombok.Data;

/**
 * @author t-zhaoheng
 * @since 2021/12/28
 */
@Data
public class ResponseData {
  int code;
  String message;
  Object data;

  public static ResponseData error() {
    ResponseData responseData = new ResponseData();
    responseData.setCode(1);
    responseData.setMessage("数据异常");
    return responseData;
  }

  public static ResponseData error(String message) {
    ResponseData responseData = new ResponseData();
    responseData.setMessage(message);
    responseData.setCode(1);
    return responseData;
  }

  public static ResponseData success(String message, Object data) {
    ResponseData responseData = new ResponseData();
    responseData.setMessage(message);
    responseData.setCode(0);
    responseData.setData(data);
    return responseData;
  }

  public static ResponseData success(Object data) {
    ResponseData responseData = new ResponseData();
    responseData.setMessage("success");
    responseData.setCode(0);
    responseData.setData(data);
    return responseData;
  }
}
